package com.example.netty.vo;

import java.util.HashSet;
import java.util.Set;

/**
 * 房间主体
 * @author zclever <304078606@qq.com>
 * @date 2021-03-02
 */
public class Room {

    /** 房间id */
    private String id;

    /** 风力风向 */
    private int wind;

    /** 房间剩余时间 */
    private int time;

    /** 用户列表 */
    private Set<User> userList = new HashSet<>();


    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public int getWind() {
        return wind;
    }

    public void setWind(int wind) {
        this.wind = wind;
    }

    public int getTime() {
        return time;
    }

    public void setTime(int time) {
        this.time = time;
    }

    public Set<User> getUserList() {
        return userList;
    }

    public void addUser(User user) {
        this.userList.add(user);
    }

    public void removeUser(User user) {
        this.userList.remove(user);
    }

    public boolean isEmpty() {
        int userCount = 0;
        for(User u : userList){
            if(!u.isRoot())userCount++;
        }
        return userCount == 0?true:false;
    }
}
